package com.fire.controller;

/**
 * ClassName: MonitorController
 * Package: com.fire.controller
 * Description:
 *
 * @Author: @weixueshi
 * @Create: 2024/4/3 - 23:30
 * @Version: v1.0
 */

import com.fire.response.ResultData;
import com.fire.service.IMonitorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 监测管理模块控制层
 */
@Slf4j
@Validated
@CrossOrigin
@RestController
@RequiredArgsConstructor
@Api(tags = {"监测管理模块"})
@RequestMapping("/monitor")
public class MonitorController {

    private final IMonitorService monitorService;

    /**
     * 分页查询监测数据
     * @return
     */
    @GetMapping("/query/like/{pageNo}/{pageSize}")
    @ApiOperation(value = "查询监测数据")
    public ResultData queryMonitorData(@PathVariable("pageNo") Integer pageNo,
                                           @PathVariable("pageSize") Integer pageSize,
                                           String location){
        Map<String,Object> map = monitorService.queryMonitorData(pageNo,pageSize,location);
        return ResultData.success(map);
    }

    /**
     * 查询城市名称
     * @return
     */
    @GetMapping("/query")
    @ApiOperation(value = "查询城市名称")
    public ResultData queryCity(){
        List<String> cities = monitorService.queryCity();
        return ResultData.success(cities);
    }

    /**
     * 将异常的监测数据处理情况修改为已处理状态
     * @param id
     * @return
     */
    @PutMapping("/update/dispose/{id}")
    @ApiOperation(value = "监测数据处理修改")
    public ResultData updateDispose(@PathVariable("id") Integer id) {
        log.info("监测数据处理修改接口请求，修改监测数据的id为：{}",id);
        monitorService.updateDispose(id);
        log.info("监测数据处理修改接口请求成功，修改监测数据的id为：{}",id);
        return ResultData.success();
    }
}
